package server

import (
	"time"
)

type ServerIdleTimeout struct {
	session *Session
}

func (x *ServerIdleTimeout) OnTimeout() {
	x.session.sessionHandle.OnIdleTimeout(x.session)
}

func (x *ServerIdleTimeout) IsTimeout() bool {
	return x.session.lastActiveAt.Add(x.session.idleTimeout).Before(time.Now())
}

func NewServerIdleTimeout(session *Session) *ServerIdleTimeout {
	return &ServerIdleTimeout{
		session: session,
	}
}
